package com.ticket.sass.admin.controller;


import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.impl.CommodityCategoryBusinessImpl;
import com.ticket.sass.admin.dto.input.commodity.category.CommodityCategoryAddInput;
import com.ticket.sass.admin.dto.input.commodity.category.CommodityCategoryListInput;
import com.ticket.sass.admin.dto.input.commodity.category.CommodityCategoryUpdInput;
import com.ticket.sass.admin.dto.output.commodity.category.CommodityCategoryListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ywb
 * @since 2024-03-23
 */
@RestController
@AllArgsConstructor
@ApiSupport(order = 6)
@Api(tags = {"卖品分类-模块"})
@RequestMapping("/commodities/categories")
public class CommodityCategoriesController {
    final CommodityCategoryBusinessImpl hallBusiness;
    

    @GetMapping
    @ApiOperation("列表")
    public ResultModel<PageModel<CommodityCategoryListOutput>> list(
        @Valid CommodityCategoryListInput input
    ) {
        return ResultModel.success(
            hallBusiness.list(input)
        );
    }
    
    @PostMapping
    @ApiOperation("新增")
    @Loggable(module = Module.COMMODITY, desc = "新增卖品分类")
    public ResultModel<String> add(
        @RequestBody @Valid CommodityCategoryAddInput input
    ) {
        hallBusiness.add(input);
        return ResultModel.success();
    }
    
    @PutMapping
    @ApiOperation("修改卖品分类")
    @Loggable(module = Module.COMMODITY, desc = "修改卖品分类")
    public ResultModel<String> upd(
        @RequestBody @Valid CommodityCategoryUpdInput input
    ) {
        hallBusiness.upd(input);
        return ResultModel.success();
    }
}
